Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Description

Terminal suggestions for ls ../ incorrectly showed files from two levels up instead of one. The getCWDForFilesAndFolders function concatenated paths without normalizing, producing /home/user/project/../ instead of /home/user/.

Changes

  • Path normalization: Added path.normalize() to getCWDForFilesAndFolders in extensions/terminal-suggest/src/fig/shared/utils.ts to resolve . and .. components before returning the directory path

  • Test coverage: Added test suite for getCWDForFilesAndFolders covering:

    • Relative parent/current directories (../, ./)
    • Child, absolute, and home directory paths
    • Complex relative paths with multiple components

Example fix:

// Before: /home/user/project/../
// After:  /home/user/
const result = dirname.startsWith('~/') || dirname.startsWith('/')
    ? dirname
    : `${cwd}/${dirname}`;

return ensureTrailingSlash(path.normalize(result));

Existing test expectations in ls.test.ts and cd.test.ts already validate this behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>terminal-suggest: ls ../ brings up wrong file suggestions</issue_title>
<issue_description>

Does this issue occur when all extensions are disabled?: Yes

Version: 1.109.0-insider (user setup)
Commit: c664b45
Date: 2026-01-12T05:02:56.770Z
Electron: 39.2.7
ElectronBuildId: 12953945
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT arm64 10.0.28000

settings.json

{
    "terminal.integrated.suggest.insertTrailingSpace": true,
    "terminal.integrated.suggest.quickSuggestions": {
        "arguments": "on",
        "commands": "on",
        "unknown": "off"
    },
    "terminal.integrated.suggest.suggestOnTriggerCharacters": true,
    "terminal.integrated.suggest.upArrowNavigatesHistory": false
}

Steps to Reproduce

In the terminal, type ls ../ and observe the files/directories that are suggested. The suggestions seem to be from 2 levels up instead of 1 level up.

I'm able to repro inside a Linux Dev Container (bash), as well as on Windows (PowerShell).

Recording

parent-dir.mp4

cc: @meganrogge
</issue_description>

Comments on the Issue (you are @copilot in this section)

@meganrogge Likely from https://github.com//pull/286407 or less likely https://github.com//pull/286850

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Add path.normalize() to getCWDForFilesAndFolders to properly resolve '..' and '.' components in paths. This fixes the issue where 'ls ../' would show suggestions from 2 levels up instead of 1 level up.

Also add comprehensive tests for getCWDForFilesAndFolders to ensure correct behavior with various path patterns.

Co-authored-by: meganrogge <[email protected]>
Copilot AI changed the title [WIP] Fix terminal suggestions for ls command Fix terminal suggest relative path normalization for ls ../ Jan 12, 2026
Copilot AI requested a review from meganrogge January 12, 2026 22:24
@meganrogge meganrogge closed this Jan 12, 2026
@gitme1-ym
Copy link

16152a795df23495c6eb50d3a63aed422f8b41d518390e584341c06e64aee532> ## Description

Terminal suggestions for ls ../ incorrectly showed files from two levels up instead of one. The getCWDForFilesAndFolders function concatenated paths without normalizing, producing /home/user/project/../ instead of /home/user/.

Changes

  • Path normalization: Added path.normalize() to getCWDForFilesAndFolders in extensions/terminal-suggest/src/fig/shared/utils.ts to resolve . and .. components before returning the directory path

  • Test coverage: Added test suite for getCWDForFilesAndFolders covering:

    • Relative parent/current directories (../, ./)
    • Child, absolute, and home directory paths
    • Complex relative paths with multiple components

Example fix:

// Before: /home/user/project/../
// After:  /home/user/
const result = dirname.startsWith('~/') || dirname.startsWith('/')
    ? dirname
    : `${cwd}/${dirname}`;

return ensureTrailingSlash(path.normalize(result));

Existing test expectations in ls.test.ts and cd.test.ts already validate this behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>terminal-suggest: ls ../ brings up wrong file suggestions</issue_title>
<issue_description>

Does this issue occur when all extensions are disabled?: Yes

Version: 1.109.0-insider (user setup)
Commit: c664b45
Date: 2026-01-12T05:02:56.770Z
Electron: 39.2.7
ElectronBuildId: 12953945
Chromium: 142.0.7444.235
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Windows_NT arm64 10.0.28000

settings.json

{
    "terminal.integrated.suggest.insertTrailingSpace": true,
    "terminal.integrated.suggest.quickSuggestions": {
        "arguments": "on",
        "commands": "on",
        "unknown": "off"
    },
    "terminal.integrated.suggest.suggestOnTriggerCharacters": true,
    "terminal.integrated.suggest.upArrowNavigatesHistory": false
}

Steps to Reproduce

In the terminal, type ls ../ and observe the files/directories that are suggested. The suggestions seem to be from 2 levels up instead of 1 level up.

I'm able to repro inside a Linux Dev Container (bash), as well as on Windows (PowerShell).

Recording

parent-dir.mp4

cc: @meganrogge
</issue_description>

Comments on the Issue (you are @copilot in this section)

@meganrogge Likely from https://github.com//pull/286407 or less likely https://github.com//pull/286850

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terminal-suggest: ls ../ brings up wrong file suggestions

3 participants